﻿<mui:ModernWindow x:Class="ModernUILogViewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mui="http://firstfloorsoftware.com/ModernUI"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                             
        xmlns:view="clr-namespace:ModernUILogViewer.View"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:helper="clr-namespace:ModernUILogViewer.Elements.Helpers"
        xmlns:conv="clr-namespace:ModernUILogViewer.Converters"
        Title="{StaticResource appTitle}" 
        IsTitleVisible="True"     
        LogoData="F1 M 27.0038,21.0029L 49.0068,21.0029L 49.0068,25.0035L 27.0038,25.0035L 27.0038,21.0029 Z M 21.0029,27.0038L 55.0077,27.0038L 55.0077,31.0043L 21.0029,31.0043L 21.0029,27.0038 Z M 25.0035,33.0046L 51.0071,33.0046L 51.0071,37.0052L 25.0035,37.0052L 25.0035,33.0046 Z M 19.0027,39.0055L 57.008,39.0054L 57.008,43.006L 19.0027,43.006L 19.0027,39.0055 Z M 27.0038,45.0063L 49.0068,45.0063L 49.0068,49.0068L 27.0038,49.0068L 27.0038,45.0063 Z M 23.0032,51.0071L 53.0074,51.0071L 53.0074,55.0077L 23.0032,55.0077L 23.0032,51.0071 Z "                  
        DataContext="{StaticResource mainVM}"     
        Width="{Binding Source={StaticResource settings}, Path=Width, Mode=TwoWay}"
        Height="{Binding Source={StaticResource settings}, Path=Height, Mode=TwoWay}"                  
        Top="{Binding Source={StaticResource settings}, Path=Top, Mode=TwoWay}"                  
        Left="{Binding Source={StaticResource settings}, Path=Left, Mode=TwoWay}"                
        Icon="Assets/Icon1.ico"
        ContentSource="/Pages/Introduction.xaml"      
        AllowDrop="True"                  
    >
    <helper:DragDropBehaviour.DragEnterCommand>
        <Binding Path="HomeVM.DragEnterCommand" />
    </helper:DragDropBehaviour.DragEnterCommand>
    <!--<mui:ModernWindow.Style>
        <Style TargetType="{x:Type mui:ModernWindow}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Source={StaticResource settings}, Path=StartWithWelcomePage}" Value="True">
                    <Setter Property="ContentSource" Value="/Pages/Introduction.xaml" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Source={StaticResource settings}, Path=StartWithWelcomePage}" Value="False">
                    <Setter Property="ContentSource" Value="/Pages/Home.xaml" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </mui:ModernWindow.Style>-->


    <Window.Resources>
        <conv:ConverterChain x:Key="nulltovisibilityconverter">
            <conv:NullToBooleanConverter />
            <BooleanToVisibilityConverter />
        </conv:ConverterChain>
    </Window.Resources>

    <mui:ModernWindow.MenuLinkGroups>
        <mui:LinkGroup DisplayName="Welcome">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="introduction" Source="/Pages/Introduction.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>        
        <mui:LinkGroup DisplayName="Main">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="entity viewer" Source="/Pages/Home.xaml" />
                <mui:Link DisplayName="log watcher" Source="/Pages/LogTail.xaml" />
                <mui:Link DisplayName="statistics" Source="/Pages/Statistics.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
        <mui:LinkGroup DisplayName="Options">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="parsing" Source="/Pages/RegexSettings.xaml" />                
                <mui:Link DisplayName="external" Source="/Pages/ExternalEditor.xaml" />                
                <mui:Link DisplayName="colors" Source="/Pages/ColorSettings.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>        
        <mui:LinkGroup DisplayName="Testing tools">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="regex" Source="/Pages/TestFile.xaml" />
                <mui:Link DisplayName="date" Source="/Pages/TestDateFormat.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
    </mui:ModernWindow.MenuLinkGroups>
    
    <mui:ModernWindow.TitleLinks>
        <mui:Link DisplayName="settings" Source="/Pages/Settings.xaml" />        
    </mui:ModernWindow.TitleLinks>
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <i:InvokeCommandAction Command="{Binding Source={StaticResource settingsmanager}, Path=SaveAppSettings}" CommandParameter="{StaticResource mainVM}"/>
        </i:EventTrigger>
        <!--<i:EventTrigger EventName="IsInitialized ">
            
        </i:EventTrigger>-->
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.InitContainer}" />
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.InitViewModel}" CommandParameter="{Binding}" />
            <i:InvokeCommandAction Command="{Binding Source={StaticResource settingsmanager}, Path=LoadInitialSettings}" CommandParameter="{StaticResource mainVM}"/>
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.RegisterMessages}"/>
            <i:InvokeCommandAction Command="{Binding NetworkVM.CheckAppUpdates}" />                        
        </i:EventTrigger>
        <i:EventTrigger EventName="SoftwareOutOfDateEvent" SourceObject="{Binding NetworkVM}">
            <view:InvokeDelegateCommandAction 
                Command="{x:Static view:ViewCommands.MessageOutOfDateVersion}"
                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" 
                />
        </i:EventTrigger>
        <i:EventTrigger EventName="HomeViewRequestedEvent" SourceObject="{Binding HomeVM}">
            <ei:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PropertyName="ContentSource" Value="/Pages/Home.xaml" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
</mui:ModernWindow>
